<?php
$this->render('include/sortLink.phtml');
$this->headScript()->appendFile(_STATIC_HTTP . '/jquery/checkAll.js');
echo $this->render('picture/special/_tab.phtml');
?>
<form action="" method="post">
<div class="body">
	<table class="list">
		<tr>
			<th class="id"></th>
			<th class="narrow sort" title="<?php echo $this->language('Display Order');?>"><?php echo __sortLink('display_order', 'D');?></th>
			<th><?php echo $this->language('INFORMATION');?></th>
			<th class="narrow sort" title="<?php echo $this->language('Photo Total Count');?>"><?php echo __sortLink('photo', 'PHOTO');?></th>
			<th class="time sort"><?php echo __sortLink('creationtime', 'CREATION');?></th>
			<th class="time sort"><?php echo __sortLink('date', 'MODIFIED');?></th>
			<th class="narrow"></th>
		</tr>
		<?php
		foreach($this->list AS $key => $row) {
			$categories = isset($this->categories[$row->getId()]) ? $this->categories[$row->getId()] : array();
			$keywords = isset($this->keywords[$row->getId()]) ? $this->keywords[$row->getId()] : array();
		?>
		<tr>
			<td class="icon"><a href="<?php echo $this->url('picture/special/photo', array('id' => $row->getId()));?>"><img src="<?php echo $row->getCover()->getThumb(false);?>" /></a></td>
			<td>
				<?php echo $this->form()->text('display_order[' . $row->getId() . ']', $row->getDisplayOrder(), array('size' => '4', 'maxlength' => '8'));?>
				<em title="Is Actived" class="<?php echo ($row->getIsActive() ? 'red' : 'gray');?>">ACT</em>
				<em title="Is Recomended" class="<?php echo ($row->getIsRecommend() ? 'red' : 'gray');?>">REC</em>
			</td>
			<td<?php if(!$row->getIsActive()) {echo ' class="gray"';}?>>
				<h3><a href="<?php echo $this->url('picture/special/edit', array('id' => $row->getId()));?>"><?php echo $this->escape($row->getTitle());?></a></h3>
				<p class="tags">
					<span><?php echo $this->language('Keyword');?>: </span><?php
					$cs = array(); 
					foreach($keywords AS $kw) {
						$cs[] = '<a href="' . $this->url('picture/special/list', array(), array('k' => $kw['name'])) . '">' . $this->escape($kw['name']) . '</a>';
					}
					echo implode($cs, ', ');
					?>
				</p>
				<p class="tags">
					<span><?php echo $this->language('Category');?>: </span><?php
					$cs = array(); 
					foreach($categories AS $category) {
						$cs[] = '<a href="' . $this->url('picture/special/list', array(), array('category_id' => $category['category_id'])) . '">' . $this->escape($category['title']) . '</a>';
					}
					echo implode($cs, ', ');
					?>
				</p>
				<p class="toolbar">
					<a href="<?php echo $this->url('picture/special/edit', array('id' => $row->getId()));?>"><?php echo $this->language('Edit');?>»</a>
					<a href="<?php echo $this->url('picture/special/photo', array('id' => $row->getId()));?>"><?php echo $this->language('Photo List');?>»</a>
					<a href="<?php echo $this->url('picture/photo/batch', array('special_id' => $row->getId()));?>" class="batch"><?php echo $this->language('Upload In Batch');?>»</a>
					<a href="<?php echo $this->url('picture/special/delete', array('id' => $row->getId()));?>"><?php echo $this->language('Delete');?>»</a>					
				</p>
			</td>
			<td class="center"><h1><?php echo $row->getPtotal();?></h1></td>
			<td class="time"><?php echo $this->date($row->getCreationtime());?></td>
			<td class="time"><?php echo $this->date($row->getLastmodified());?></td>
			<td></td>
		</tr>
		<?php } ?>
		<?php if(count($this->list) <= 0) {?>
		<tr>
			<td colspan="7" class="nohover">
				<div class="msg">
					<div class="common error" style="border:0;background:#fff;">
						<i class="icon"></i>
						<h4>STOP</h4>
						<div class="msg-bd">
							No Special found. 
							<a href="<?php echo $this->url('picture/special/addnew', array(), array('category_id' => intval($this->category_id)));?>"><?php echo $this->language('Create');?>..</a>
						</div>
					</div>
				</div>
			</td>
		</tr>
		<?php } ?>
	</table>
</div>
<div class="body">
	<div style="float:right;margin-bottom:5px;">
		<button type="reset" value="reset" onclick="return confirm('<?php echo $this->language('Reset all values you changed');?>?');"><?php echo $this->language('Reset');?></button>
		<button type="submit" value="submit" style="margin-right:0;" onclick="return confirm('<?php echo $this->language('Are you sure to Save all changes');?>?');"><?php echo $this->language('Save Changes');?></button>
	</div>
	<?php echo $this->paginator($this->list)->render();?>
</div>
</form>
